import { Http } from "@/utils/request";
import { Toast } from "@/utils/toast";
import { delayTask } from "@/utils/timer";

const baseUrl = "/tour";

export const course_api = (
  data: { course_type: number } & MiniApp.PagingQuery,
  showError = true
) => {
  return Http.get<{ course_list: MiniApp.PagingData }>(
    `${baseUrl}/course`,
    data
  )
    .then(resp => resp.course_list)
    .catch((error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    });
};
